import { reactive } from 'vue'
// import { useI18n } from '@/hooks/web/useI18n'
import { required } from '@/utils/formRules'
import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas'
// const { t } = useI18n() // 国际化
// 表单校验
export const rules = reactive({
  modelId: [required],
  title: [required]
})
// CrudSchema
const crudSchemas = reactive<VxeCrudSchema>({
  primaryKey: 'id', // 默认的主键ID
  primaryTitle: 'ID', // 默认显示的值
  primaryType: 'id', // 默认为seq，序号模式
  action: true,
  actionWidth: '400', // 3个按钮默认200，如有删减对应增减即可
  columns: [
    {
      title: 'ID',
      field: 'id',
      isTable: true
    },
    {
      title: '标题',
      field: 'title',
      isSearch: true,
      table: {
        slots: {
          default: 'title_default'
        }
      }
    },
    {
      title: '栏目',
      field: 'channelName',
      isSearch: false,
      isTable: true
    },
    {
      title: '发布时间',
      field: 'releaseTime',
      form: {
        component: 'DatePicker',
        componentProps: {
          type: 'datetime',
          valueFormat: 'x'
        }
      },
      formatter: 'formatDate',
      search: {
        show: true,
        itemRender: {
          name: 'XDataTimePicker'
        }
      }
    },
    {
      title: '状态',
      field: 'status',
      dictType: DICT_TYPE.CMS_CONTENT_STATUS,
      dictClass: 'number',
      isSearch: true
    },
    {
      title: '置顶',
      field: 'topLevel',
      dictType: DICT_TYPE.CMS_OPEN_CLOSE,
      dictClass: 'number',
      isSearch: true,
      isTable: false
    },
    {
      title: '标记',
      field: 'dictMark',
      dictType: DICT_TYPE.CMS_CONTENT_MARKS,
      dictClass: 'number',
      isSearch: true,
      isTable: false
    },
    {
      title: '区块',
      field: 'dictBlock',
      dictType: DICT_TYPE.CMS_CONTENT_BLOCKS,
      dictClass: 'number',
      isSearch: true,
      isTable: false
    },
    {
      title: '部门',
      field: 'deptId',
      form: {
        component: 'InputNumber',
        value: 0
      },
      isSearch: false,
      isTable: false
    }
  ]
})
export const { allSchemas } = useVxeCrudSchemas(crudSchemas)
